package wysiwyg.client.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.widget.core.client.TabItemConfig;
import com.sencha.gxt.widget.core.client.TabPanel;
import com.sencha.gxt.widget.core.client.info.Info;

public class BasicTabWidget implements IsWidget {

	@UiTemplate("BasicTabWidget.ui.xml")
	interface MyUiBinder extends UiBinder<Widget, BasicTabWidget> {

	}

	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
	@UiField(provided = true)
	String txt = "DUMMY_TEXT_SHORT";

	public Widget asWidget() {
		return uiBinder.createAndBindUi(this);
	}

	@UiHandler(value = { "folder"  })
	void onSelection(SelectionEvent<Widget> event) {
		TabPanel panel = (TabPanel) event.getSource();
		Widget w = event.getSelectedItem();
		TabItemConfig config = panel.getConfig(w);
		Info.display("Message", "'" + config.getText() + "' Selected");
	}
}